const movieModel = require('../models/movie.model.js');

const getMovies = async (req, res) => {
    try {
        const movies = await movieModel.getMovies();
        res.status(200).json(movies);
    } catch (error) {
        res.status(500).json({ message: 'Error fetching movies', error: error.message });
    }
};

const createMovie = async (req, res) => {
    const { title, description, duration, release_date } = req.body;
    try {
        const movieId = await movieModel.createMovie(title, description, duration, release_date);
        res.status(201).json({ message: 'Movie created successfully', movieId });
    } catch (error) {
        res.status(500).json({ message: 'Error creating movie', error: error.message });
    }
};

module.exports = {
    getMovies,
    createMovie
};